//
//  ActionCollectionCell.m
//  projecthz
//
//  Created by YDJH on 2017/4/19.
//  Copyright © 2017年 tali. All rights reserved.
//

#import "ActionCollectionCell.h"
#import "Masonry.h"

@interface ActionCollectionCell()

@property (strong, nonatomic) UIImageView *posterView;

@property (strong, nonatomic) UILabel *actionLabel;
@property (nonatomic,copy)Actions_CallBack ActionsCallBack;

@end

NSString *const ActionsCollectionViewCellID = @"ActionsCollectionViewCellID";

@implementation ActionCollectionCell

- (UIImageView *)posterView {
    if (!_posterView) {
        _posterView = [UIImageView new];
//        _posterView.backgroundColor = [UIColor blueColor];
        _posterView.contentMode = UIViewContentModeScaleAspectFill;
        _posterView.clipsToBounds = YES;
        //        [self.contentView addSubview:_posterView];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImageAction:)];
        [_posterView addGestureRecognizer:tap];
        
        
    }
    return _posterView;
}

- (UILabel *)actionLabel {
    if (!_actionLabel) {
        _actionLabel = [UILabel new];
        _actionLabel.textAlignment = NSTextAlignmentCenter;
        _actionLabel.textColor = [UIColor whiteColor];
    }
    return _actionLabel;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupViews];
    }
    
    return self;
}

- (void)setupViews {
    if (_posterView) {
        return;
    }
    
    self.contentView.backgroundColor = [UIColor grayColor];
//    self.contentView.backgroundColor = [UIColor whiteColor];
    
    
//    [self.contentView addSubview:self.posterView];
    //    self.posterView.userInteractionEnabled = YES;
//    [self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.contentView);
//    }];
    
//    [self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.and.right.and.top.mas_equalTo(self.contentView);
//        make.height.equalTo(self.posterView.mas_width);
//    }];
    
    [self.contentView addSubview:self.actionLabel];
    [self.actionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.mas_equalTo(self.contentView);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.height.offset(20);
    }];
    
    
}

- (void)configureCellWithData:(id)data withCallBack:(Actions_CallBack)callBack {
//    NSString *name = data;
//    _posterView.image = [UIImage imageNamed:@"check"];
    
    NSString *action = data;
    self.actionLabel.text = action;
    self.ActionsCallBack = callBack;

}

- (void)selectImageAction:(UITapGestureRecognizer *)gestureRecognizer {
    
//    UIImageView *imageView =gestureRecognizer.view;
//    self.ActionsCallBack(<#NSString *type#>)(imageView);
}

@end
